home *** CD-ROM | disk | FTP | other *** search
-
-
-
- /*
- ** mkalist
- **
- ** Creates an unsorted index of the start of each call area in
- ** the database.
- **
- ** Copyright (c) 1993 by Fred Lloyd, AA7BQ
- **
- */
-
- #include <stdio.h>
- #include <string.h>
- #include "cb.h"
-
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- FILE *fp;
- FILE *op;
- long pos;
- long start;
- char str[1024];
- char buf[40];
- char *p;
- int acount;
- int total;
- char area;
-
- if (!argv[1])
- {
- printf("Usage: %s dbase_name\n",argv[0]);
- exit(1);
- }
- if ((fp=fopen(argv[1],"r")) == NULL)
- {
- printf("Error opening file %s.\n",argv[1]);
- exit(1);
- }
- if ((op=fopen("alist.lst","w")) == NULL)
- {
- printf("Error opening nlist.ndx\n");
- exit(1);
- }
- acount = 0;
- total = 0;
- area = '0';
- start = 0;
- printf("\n");
- while (!feof(fp))
- {
- memset(str,0,sizeof(str));
- pos = ftell(fp);
- fgets(str,sizeof(str),fp);
- if (!strlen(str))
- break;
-
- p = strchr(str,',');
- if (p)
- *p = '\0';
- else
- continue;
-
- acount++;
- if (p=strchr(str,area))
- continue;
-
- printf("Area %c, start %ld, end %ld, total %d\n",area,
- start, pos, acount);
-
- fprintf(op, "%c %ld %ld %d\n",area,start,pos,acount);
-
- area++;
- total += acount;
- acount = 0;
- start = pos;
- }
- printf("Area %c, start %ld, end %ld, total %d\n",area,
- start, pos, acount);
-
- fprintf(op, "%c %ld %ld %d\n",area,start,pos,acount);
- printf("\nTotal: %d\n",total);
- fclose(fp);
- fclose(op);
- exit(0);
- }
-
-